<?php

namespace App\Trip\Orders\BookOrders\Train\PriceDetails\AbstractPriceDetails;

use App\Models\Trip\TripOrderCosts\TripOrderCost;
use Illuminate\Support\Collection;

abstract class AbstractPriceDetails
{
    /**
     * 订单金额
     *
     * @return float
     */
    public abstract function getOrderAmount(): float;

    /**
     * 订单应收金额
     *
     * @return float
     */
    public abstract function calcReceivable(): float;

    /**
     * 原订单应退金额
     *
     * @return float
     */
    public abstract function calcOriginNeedRefundAmount(): float;

    public abstract function getPassengers(): array;

    public abstract function getServiceFee(): float;

    /**
     * 构造新的票价 编辑成功后 如果需要支付 比较当前票价 与 已存在的票价 + 差价
     *
     * @return Collection
     */
    public function getPriceDetails4Ticket(): Collection
    {
        return collect($this->getDetails())->where('type', TripOrderCost::COST_TYPE_TICKET);
    }

    /**
     * 票价明细
     *
     * @return array
     */

    public function getDetails(): array
    {
        return $this->getPriceDetails()['details'];
    }

    /**
     * 订单金额明细
     *
     * @return array
     */
    public abstract function getPriceDetails(): array;
}